package com.fdb.efp.nls.service.impl.sx.zxruleforbd;

import com.fdb.cdp.pboc.service.vo.BdZxInfoVO;
import com.fdb.efp.rule.service.vo.ReqBdCreditRuleVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.stream.Stream;

/**
 * 任意一张贷记卡当前状态为:"逾期","呆账","冻结","止付" <br>
 * <p>
 * 0.1:caoxin:2019/7/10 17:03: 借款人年龄小于23, 借款人年龄大于55周岁: <br>
 *
 * @author caoxin
 * @version 0.1
 * @date 2019/7/10 17:03
 * @since 2019/7/10 17:03
 */
@Service("bDZxRule02")
public class BDZxRule02 implements BdZxRuleInterface {
    @Override
    public void executeRule(ReqBdCreditRuleVo reqBdCreditRuleVo, BdZxInfoVO bdZxInfoVO) {
        // 贷记卡，准贷记卡当前账户最严重状态不等于正常
        int sum = 0;
        Integer sum1 = Stream.of(bdZxInfoVO.getZxCreCardStatus1()).
                filter(StringUtils::isNotEmpty).
                filter(StringUtils::isNotEmpty).filter(t -> {
            return t.equals("逾期") || t.equals("呆账") || t.equals("冻结") || t.equals("止付");
        }).map(e -> 1).reduce(0, Integer::sum);
        if (sum1 > 0) {
            sum = 1;
        }
        reqBdCreditRuleVo.setRule02(sum);
    }
}
